#include <iostream>
#include <fstream>
#include <string>
#include <memory>
#include <jsoncpp/json/json.h>
using namespace std;
int main()
{
    // data
    string name("ZhangSan");
    int age = 18;
    float scores[] = {77, 88, 99, 11.111};
    // josn val
    Json::Value val;
    // k-v
    val["name"] = name;
    val["age"] = age;
    for (int i = 0; i < sizeof(scores) / sizeof(float); i++)
        val["scores"].append(scores[i]);
    //new
    Json::StreamWriterBuilder swb;
    unique_ptr<Json::StreamWriter> p_writer(swb.newStreamWriter());
    ofstream fout("data.json");
    //deser->out
    if (p_writer->write(val, &fout))
        return -1;
    return 0;
}